package com.hnjowe.util;

import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;

/**
 * @短信发送
 * @projectname：cocotour
 * @packagename：com.hnjowe.util
 * @filename：Sms.java
 * @date：2011-6-4 上午01:14:31
 * @author: wangxiuwu
 */
public class Sms {
	
	private static Sms instance = null;
	
	/*短信接口参数*/
    private static String sms_http = "http://notice.zuitu.com/sms";
    private static String sms_user = "wangxiuwu";
    private static String sms_pwd = "zw!QAZopen";

	public Sms() {
		// TODO Auto-generated constructor stub
	}
	
	/**
     * 返回一个TimeFormat类的单一实例
     * @return m_instance
     */
    public synchronized  static Sms getInstance(){
    	if(instance == null){
    		instance = new Sms();
    	}
    	return instance;
    }
	
    
    /**
	 * 短信发送
	 */
	public void smsSend(String phones, String content){

		try{
			Map<String, String> params = new HashMap<String, String>();
			params.put("user", sms_user);
			params.put("pass", MD5.md5(sms_pwd).toLowerCase());
			params.put("phones", phones);
			params.put("content", URLEncoder.encode(content, "utf-8"));
			
			Map<String, String> propertys = new HashMap<String, String>();
			params.put("Content-type", "text/html");
			params.put("Accept-Charset", "utf-8");
			params.put("contentType", "utf-8");
			
			HttpRequester req = new HttpRequester();
			req.setDefaultContentEncoding("utf-8");
			
			req.sendGet(sms_http, params, propertys);
			
		}catch(Exception e){}
	}
	
	

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		System.out.println("短信发送：13322000177");
		Sms.getInstance().smsSend("13322000177", "测试abc");

	}

}
